package com.pl.study.mapreduce;

import com.pl.study.mapreduce.vo.FlowVo;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

/**
 * <p>
 *
 * @Description: driver
 * </p>
 * @ClassName FlowStatisticsDriver
 * @Author pl
 * @Date 2022/3/10
 * @Version V1.0.0
 */
public class FlowStatisticsDriver {

    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {

        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf);

        job.setJarByClass(FlowStatisticsDriver.class);

        job.setMapperClass(FlowStatisticMap.class);
        job.setReducerClass(FlowStatisticReduce.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(FlowVo.class);

        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(FlowVo.class);


        FileInputFormat.setInputPaths(job, new Path("D:\\Study\\jikeuijm\\dauuju\\week_two\\test_data\\input_data\\HTTP_20130313143750.dat"));
        FileOutputFormat.setOutputPath(job, new Path("D:\\Study\\jikeuijm\\dauuju\\week_two\\test_data\\output_data\\output"));

        boolean result = job.waitForCompletion(true);
        System.exit(result ? 0 : 1);
    }
}